home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol E-12 / (Vol E-12) May 21 2012.iso / Animations / dj / dj.swf / scripts / __Packages / mx / core / ExternalContent.as next >
Text File  |  2012-05-21  |  5KB  |  147 lines

  1. class mx.core.ExternalContent
  2. {
  3.    static var classConstructed = mx.core.ExternalContent.classConstruct();
  4.    static var ViewDependency = mx.core.View;
  5.    function ExternalContent()
  6.    {
  7.    }
  8.    function loadExternal(url, placeholderClassName, instanceName, depth, initProps)
  9.    {
  10.       var _loc2_ = undefined;
  11.       _loc2_ = this.createObject(placeholderClassName,instanceName,depth,initProps);
  12.       this[mx.core.View.childNameBase + this.numChildren] = _loc2_;
  13.       if(this.prepList == undefined)
  14.       {
  15.          this.prepList = new Object();
  16.       }
  17.       this.prepList[instanceName] = {obj:_loc2_,url:url,complete:false,initProps:initProps};
  18.       this.prepareToLoadMovie(_loc2_);
  19.       return _loc2_;
  20.    }
  21.    function prepareToLoadMovie(obj)
  22.    {
  23.       obj.unloadMovie();
  24.       this.doLater(this,"waitForUnload");
  25.    }
  26.    function waitForUnload()
  27.    {
  28.       var _loc3_ = undefined;
  29.       for(_loc3_ in this.prepList)
  30.       {
  31.          var _loc2_ = this.prepList[_loc3_];
  32.          if(_loc2_.obj.getBytesTotal() == 0)
  33.          {
  34.             if(this.loadList == undefined)
  35.             {
  36.                this.loadList = new Object();
  37.             }
  38.             this.loadList[_loc3_] = _loc2_;
  39.             _loc2_.obj.loadMovie(_loc2_.url);
  40.             delete this.prepList[_loc3_];
  41.             this.doLater(this,"checkLoadProgress");
  42.          }
  43.          else
  44.          {
  45.             this.doLater(this,"waitForUnload");
  46.          }
  47.       }
  48.    }
  49.    function checkLoadProgress()
  50.    {
  51.       var _loc3_ = undefined;
  52.       for(_loc3_ in this.loadList)
  53.       {
  54.          var _loc2_ = this.loadList[_loc3_];
  55.          _loc2_.loaded = _loc2_.obj.getBytesLoaded();
  56.          _loc2_.total = _loc2_.obj.getBytesTotal();
  57.          if(_loc2_.total > 0)
  58.          {
  59.             _loc2_.obj._visible = false;
  60.             this.dispatchEvent({type:"progress",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  61.             if(_loc2_.loaded == _loc2_.total)
  62.             {
  63.                if(this.loadedList == undefined)
  64.                {
  65.                   this.loadedList = new Object();
  66.                }
  67.                this.loadedList[_loc3_] = _loc2_;
  68.                delete this.loadList[_loc3_];
  69.                this.doLater(this,"contentLoaded");
  70.             }
  71.          }
  72.          else if(_loc2_.total == -1)
  73.          {
  74.             if(_loc2_.failedOnce != undefined)
  75.             {
  76.                _loc2_.failedOnce = _loc2_.failedOnce + 1;
  77.                if(_loc2_.failedOnce > 3)
  78.                {
  79.                   this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  80.                   delete this.loadList[_loc3_];
  81.                   false;
  82.                }
  83.             }
  84.             else
  85.             {
  86.                _loc2_.failedOnce = 0;
  87.             }
  88.          }
  89.          this.doLater(this,"checkLoadProgress");
  90.       }
  91.    }
  92.    function contentLoaded()
  93.    {
  94.       var _loc4_ = undefined;
  95.       for(_loc4_ in this.loadedList)
  96.       {
  97.          var _loc2_ = this.loadedList[_loc4_];
  98.          _loc2_.obj._visible = true;
  99.          _loc2_.obj._complete = true;
  100.          var _loc3_ = undefined;
  101.          for(_loc3_ in _loc2_.initProps)
  102.          {
  103.             _loc2_.obj[_loc3_] = _loc2_.initProps[_loc3_];
  104.          }
  105.          this.childLoaded(_loc2_.obj);
  106.          this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  107.          delete this.loadedList[_loc4_];
  108.          false;
  109.       }
  110.    }
  111.    function convertToUIObject(obj)
  112.    {
  113.       if(obj.setSize == undefined)
  114.       {
  115.          var _loc2_ = mx.core.UIObject.prototype;
  116.          obj.addProperty("width",_loc2_.__get__width,null);
  117.          obj.addProperty("height",_loc2_.__get__height,null);
  118.          obj.addProperty("left",_loc2_.__get__left,null);
  119.          obj.addProperty("x",_loc2_.__get__x,null);
  120.          obj.addProperty("top",_loc2_.__get__top,null);
  121.          obj.addProperty("y",_loc2_.__get__y,null);
  122.          obj.addProperty("right",_loc2_.__get__right,null);
  123.          obj.addProperty("bottom",_loc2_.__get__bottom,null);
  124.          obj.addProperty("visible",_loc2_.__get__visible,_loc2_.__set__visible);
  125.          obj.move = mx.core.UIObject.prototype.move;
  126.          obj.setSize = mx.core.UIObject.prototype.setSize;
  127.          obj.size = mx.core.UIObject.prototype.size;
  128.          mx.events.UIEventDispatcher.initialize(obj);
  129.       }
  130.    }
  131.    static function enableExternalContent()
  132.    {
  133.    }
  134.    static function classConstruct()
  135.    {
  136.       var _loc1_ = mx.core.View.prototype;
  137.       var _loc2_ = mx.core.ExternalContent.prototype;
  138.       _loc1_.loadExternal = _loc2_.loadExternal;
  139.       _loc1_.prepareToLoadMovie = _loc2_.prepareToLoadMovie;
  140.       _loc1_.waitForUnload = _loc2_.waitForUnload;
  141.       _loc1_.checkLoadProgress = _loc2_.checkLoadProgress;
  142.       _loc1_.contentLoaded = _loc2_.contentLoaded;
  143.       _loc1_.convertToUIObject = _loc2_.convertToUIObject;
  144.       return true;
  145.    }
  146. }
  147.